package com.caoaman.sharding.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName: DateUtil
 * @Description: 时间工具类
 * @Author: CaoAMan
 * @Create: 2021-12-18 15:57
 */
public class DateUtil {


    private static final SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy");

    private static final SimpleDateFormat monthFormat = new SimpleDateFormat("MM");

    private static final SimpleDateFormat yearJoinMonthFormat = new SimpleDateFormat("yyyyMM");


    public static String getYearByMillisecond(long millisecond) {
        return yearFormat.format(new Date(millisecond));
    }


    public static String getMonthByMillisecond(long millisecond) {
        return monthFormat.format(new Date(millisecond));
    }


    public static String getYearJoinMonthByMillisecond(long millisecond) {
        return yearJoinMonthFormat.format(new Date(millisecond));
    }

}
